using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class CategoryProductInfo
    {
		#region Local Variable
		public enum Field
		{
			IDCode,
			IDProduct,
			Status,
			Note
		}
		private Int32 _IDCode;
		private Int64 _IDProduct;
		private String _Status;
		private String _Note;
		
		public Int32 IDCode{	get{ return _IDCode;} set{_IDCode = value;} }
		public Int64 IDProduct{	get{ return _IDProduct;} set{_IDProduct = value;} }
		public String Status{	get{ return _Status;} set{_Status = value;} }
		public String Note{	get{ return _Note;} set{_Note = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public CategoryProductInfo()
		{
			_IDCode = 0;
			_IDProduct = 0;
			_Status = "";
			_Note = "";
		}
		public CategoryProductInfo(
		Int32 IDCode,
		Int64 IDProduct,
		String Status,
		String Note
		)
		{
			_IDCode = IDCode;
			_IDProduct = IDProduct;
			_Status = Status;
			_Note = Note;
		}
		public CategoryProductInfo(DataRow dr)
		{
			if (dr != null)
			{
				_IDCode = dr[Field.IDCode.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDCode.ToString()]);
				_IDProduct = dr[Field.IDProduct.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.IDProduct.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
				_Note = dr[Field.Note.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Note.ToString()]);
			}
		}
		public CategoryProductInfo(CategoryProductInfo objEntr)
		{			
			_IDCode = objEntr.IDCode;			
			_IDProduct = objEntr.IDProduct;			
			_Status = objEntr.Status;			
			_Note = objEntr.Note;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("CategoryProduct");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.IDCode.ToString(), typeof(Int32)),
				new DataColumn(Field.IDProduct.ToString(), typeof(Int64)),
				new DataColumn(Field.Status.ToString(), typeof(String)),
				new DataColumn(Field.Note.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.IDCode.ToString()] = _IDCode;
			row[Field.IDProduct.ToString()] = _IDProduct;
			row[Field.Status.ToString()] = _Status;
			row[Field.Note.ToString()] = _Note;
			return row;
		}
        #endregion InitTable
    }
}
